home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 API Bible / Windows 95 API Bible 3 Disc Set.iso / Win32 API Bible Book 1 of 3 / CHAPTE21 / EX9.C < prev    next >
C/C++ Source or Header  |  1995-05-29  |  2KB  |  51 lines

  1. #include <genstub.c>
  2.  
  3. LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  4. {
  5.    static DWORD rgbIniActiveCaption;
  6.    static DWORD rgbIniInactiveCaption;
  7.  
  8.    switch (uMsg)
  9.    {
  10.          case WM_CREATE:     // store initial values of colors
  11.                rgbIniActiveCaption = GetSysColor( COLOR_ACTIVECAPTION );
  12.                rgbIniInactiveCaption = GetSysColor( COLOR_INACTIVECAPTION );
  13.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  14.          case WM_COMMAND:
  15.                switch ( LOWORD( wParam ) )
  16.                {
  17.                      case IDM_TEST:
  18.                      {
  19.                            DWORD rgbs[2];    // new color values
  20.                            UINT dispEls[2];  // elements affected
  21.  
  22.                            rgbs[0] = RGB( 255, 0, 0 );       // RED
  23.                            dispEls[0] = COLOR_ACTIVECAPTION;
  24.                            rgbs[1] = RGB( 0, 255, 0 );       // GREEN
  25.                            dispEls[1] = COLOR_INACTIVECAPTION;
  26.                            SetSysColors( 2, &dispEls, &rgbs );
  27.                      }
  28.                      break;
  29.                      case IDM_EXIT:
  30.                            DestroyWindow( hWnd );
  31.                            break;
  32.                }
  33.                break;
  34.                case WM_DESTROY:
  35.                {  // Return colors to stored initial values.
  36.                      DWORD rgbs[2];
  37.                      UINT dispEls[2];
  38.  
  39.                      rgbs[0] = rgbIniActiveCaption;
  40.                      dispEls[0] = COLOR_ACTIVECAPTION;
  41.                      rgbs[1] = rgbIniInactiveCaption;
  42.                      dispEls[1] = COLOR_INACTIVECAPTION;
  43.                      SetSysColors( 2, &dispEls, &rgbs );
  44.                      PostQuitMessage( 0 );
  45.                }
  46.                break;
  47.          default:
  48.                return (DefWindowProc(hWnd, uMsg, wParam, lParam));
  49.    }
  50.    return (NULL);
  51. }